/*
 * Copyright (C) 2008, Velocityme Partnership
 * ShowDefaultAction.java
 *
 * Created on 30 August 2008, 20:47
 */

package com.velocityme.www.interfaces;

import com.velocityme.www.actionforms.NodeIdActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author  Robert
 */
public class ShowNodeIdAction extends org.apache.struts.action.Action {
    
    /** Creates a new instance of ShowNodeIdAction */
    public ShowNodeIdAction() {
    }
    
    /** Set nodePK in request */
    @Override
    public ActionForward execute(ActionMapping mapping, 
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws Exception {
        NodeIdActionForm node = (NodeIdActionForm)form;
        HttpSession session = request.getSession();
        if (node.getNodeId() == 0)
            node.setNodeId((Long)session.getAttribute("nodeId"));
        Long nodeId = node.getNodeId();
        request.setAttribute("nodeId", nodeId);
        return mapping.findForward("ACTION_SUCCESS");
    }
        
}
